-
-
Notifications
You must be signed in to change notification settings - Fork 835
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add debug logs to ASGIDispatch #371
Conversation
Since we show headers for the non-ASGI loggers, should we consider showing them here as well? |
Good point @sethmlarson, which made me realize there were much more data we'd be interested in seeing. We now dump all of the ASGI scope and events, which yields something like this: 22:35:40.591 - httpx.dispatch.asgi - started type='http' asgi={'version': '3.0'} http_version='1.1' method='GET' headers=[(b'host', b'app'), (b'user-agent', b'python-httpx/0.7.3'), (b'accept', b'*/*'), (b'accept-encoding', b'gzip, deflate, br'), (b'connection', b'keep-alive')] scheme='https' path='/' query_string=b'' server='app' client=('127.0.0.1', 123) root_path=''
22:35:40.591 - httpx.dispatch.asgi - received type='http.response.start' status=200 headers=[[b'content-type', b'text/plain']]
22:35:40.591 - httpx.dispatch.asgi - received type='http.response.body' body='<13 bytes>'
22:35:40.594 - httpx.dispatch.asgi - completed |
cf3160d
to
a1251c5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I just thought of we should refactor then this is good to go!
Can this logger middleware be made more generic for requests, or is is specific to ASGI apps only? |
@StephenBrown2 Its very much specific to ASGI. Our other loggers typically log h11/h2 events, I don’t see a way we can reconcile them with this. I hope having « ASGI » present in the name of the logger middleware (because it is an ASGI middleware, ie it implements the ASGI interface) conveys this intent well enough. |
Aye! |
a1251c5
to
3e6ab1a
Compare
78b8b06
to
2c5f545
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good after one comment!
Working on and debugging #352, I noticed we didn't have debug logs for the
ASGIDispatch
, so here they are. :)Example output: